#include <stdio.h>
#include <stdlib.h>
#include "sqlist.h"

int main()
{
    sqlist *list;
    datatype arr[] = {1,2,3,5,3,2,13};
    int err;
    // list = sqlist_create();
    sqlist_create1(&list);
    if(list == NULL){
        fprintf(stderr,"sqlist_create() failed!\n");
        exit(1);
    }
    for(int i = 0;i < sizeof(arr) / sizeof(*arr); ++i){
        if((err = sqlist_insert(list,0,&arr[i])) != 0){
            if(err == -1){
                fprintf(stderr,"The arr is full\n");
                exit(1);
            }else if(err == -2){
                fprintf(stderr,"The pos you want to insert is wrong\n");
                exit(1);
            }else{
                fprintf(stderr,"error\n");
                exit(1);
            }
        }
    }


    sqlist *list1;
    datatype arr1[] = {43,32,12,3,2,13};
    // list = sqlist_create();
    sqlist_create1(&list1);
    if(list1 == NULL){
        fprintf(stderr,"sqlist_create() failed!\n");
        exit(1);
    }
    for(int i = 0;i < sizeof(arr1) / sizeof(*arr1); ++i){
        if((err = sqlist_insert(list1,0,&arr1[i])) != 0){
            if(err == -1){
                fprintf(stderr,"The arr is full\n");
                exit(1);
            }else if(err == -2){
                fprintf(stderr,"The pos you want to insert is wrong\n");
                exit(1);
            }else{
                fprintf(stderr,"error\n");
                exit(1);
            }
        }
    }
    sqlist_display(list1);
    sqlist_union(list,list1);
    sqlist_display(list);

    // sqlist_delete(list,1);


    
    
    sqlist_destory(list);
    exit(0);
}